﻿@model Site3AI.Models.CmsCatalog

@{
    ViewBag.Title = "Edit";
}
@*<link href="~/Content/select2-bootstrap.css" rel="stylesheet" />
<link href="~/Content/select2.css" rel="stylesheet" />*@

<h2>Edit</h2>

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>CmsCatalog</legend>

        @Html.HiddenFor(model => model.ID)

        <div class="editor-label">
            @Html.LabelFor(model => model.PID)
        </div>
        <div class="editor-field">
            @{
    var sl = (ViewBag.CmsCatalogs as IEnumerable<Site3AI.Models.CmsCatalog>).Where(v=>v.ID!=Model.ID).Select(v => new { ID = v.ID, Title = "["+v.Title + ":"+v.ID+"]" + string.Join(",", v.Hospitals.Select(j => j.HospCode).ToArray()) });
                }
            @Html.DropDownListFor(model => model.PID, new SelectList(sl, "ID", "Title", Model.PID))
            @Html.ValidationMessageFor(model => model.PID)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Title)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Title)
            @Html.ValidationMessageFor(model => model.Title)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.SortIdx)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.SortIdx)
            @Html.ValidationMessageFor(model => model.SortIdx)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.TypeFlag)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.TypeFlag)
            @Html.ValidationMessageFor(model => model.TypeFlag)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Hospitals)
        </div>
        <div class="editor-field">
            @{
    var ho = Model.Hospitals.FirstOrDefault();
    var hv = "";
    if (null != ho)
    {
        hv = ho.HospitalID;
    }    
            }
            @Html.DropDownList("Hospital", new SelectList(ViewBag.Hospitals, "HospitalID", "HospName", hv), "<继承>")
            @*            @Html.DropDownListFor(model => model.Hospitals, new SelectList(ViewBag.Hospitals, "HospitalID", "HospName", ""), "<继承>")*@

        </div>


        <br />
        <p>
            <input type="submit" value="Save" class="btn btn-danger" />
        </p>
    </fieldset>
}
<hr />
<div>
    @Html.ActionLink("Back to List", "ListCata")
</div>
@section scripts{
    @*    <script src="~/Scripts/select2.min.js"></script>
    <script src="~/Scripts/select2_locale_zh-CN.js"></script>*@
    <script type="text/ecmascript">
        $(function () {
            //$("#Hospitals").select2();
@*                        @{
                            var ho = Model.Hospitals.FirstOrDefault();
                            var hv = "";
                            if (null != ho)
                            {
                                hv = ho.HospitalID;
                            }    
            }
            $("#Hospital").val("@hv");*@

        });

    </script>
}
